package com.zrrd.yunchmall.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author yekong
 */
@Component
public class RequestOriginParserDefinition implements RequestOriginParser {

    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {

        //1、参数名不一定是serviceName，任意参数名都可
        //2、必须是请求参数吗？ 不是，请求头的值也可以做授权规则限制
        //   例如：httpServletRequest.getHeader("token")获取请求头
        return httpServletRequest.getParameter("serviceName");
    }
}
